package com.fm.projects.crm;

import org.openqa.selenium.By;
import org.openqa.selenium.Keys;

import static com.fm.keywords.WebUI.*;

public class CommonPageCMS {


    private By menuProducts = By.xpath("//span[normalize-space()='Products']");
    private By menuCategory = By.xpath("//span[normalize-space()='Category']");
    private By menuBrand = By.xpath("//span[normalize-space()='Brand']");
    private By menuAddNewProduct = By.xpath("//span[normalize-space()='Add New Product']");
    private By menuAllProducts = By.xpath("//span[normalize-space()='All products']");
    private By messageNotify = By.xpath("//span[@data-notify='message']");
    private By buttonEdit = By.xpath("(//a[@title='Edit'])[1]");
    private By buttonSave = By.xpath("//button[normalize-space()='Save']");
    private By inputSearch = By.xpath("//input[@id='search']");
    public By avatarProfile = By.xpath("//span[contains(@class,'avatar avatar-sm')]");
    public By buttonCookies = By.xpath("//button[normalize-space()='Ok. I Understood']");


    public void enterDataOnSearchDataTable(String value) {
        setText(inputSearch, value, Keys.ENTER);
    }

    public void clickEditButton() {
        clickElement(buttonEdit);
    }
    public void clickSaveButton() {
        clickElement(buttonSave);
    }

    public String getMessageNotify() {
        return getTextElement(messageNotify);
    }

    public CommonPageCMS clickMenuProducts() {
        clickElement(menuProducts);
        return this;
    }
}
